//*********************************************************
//
// Registers used:
//   r4 - for lighting calculations (r4.w - specular power)
//   r5 - diffuse accumulation buffer
//   r6 - specular accumulation buffer
//   r7 - vertex-to-eye vector
//
// Output Registers used:
//   oD0  - diffuse color
//   oD1  - specular color
//
//*********************************************************

// Ambient light color
mov r5, c[VL_AMBIENT_COLOR_1]
mov r6, c[CONSTANT_0_05_1_2].xxxz

//commmon calculations begin
mov r4.w, c[MATERIAL_SPECULAR_POWER].w

//eye-to-vertex vector
sub r7, c[MODEL_SPACE_CAMERA_POS_OOFOG_RANGE], inPos
dp3 r7.w, r7, r7
rsq r7.w, r7.w
mul r7, r7, r7.w
//common calculations end

#include "_vertex_directional_light.vsh"

// Point light
#define SHIFT 0
#include "_vertex_point_light.vsh"
#undef SHIFT

// Point light
#define SHIFT VL_REGISTER_SHIFT_POINT
#include "_vertex_point_light.vsh"
#undef SHIFT

//calculating diffuse
mul r5, r5, c[MATERIAL_DIFFUSE_OPACITY]
mul oD0.rgb, r5, c[CONSTANT_0_05_1_2].y // color * 0.5 to compensate MUTIPLY_X2
mul oD0.a, r5, inNormal.w		// alpha * fog to make objects dissove

//calculating specular
mul r6.rgb, r6, c[MATERIAL_SPECULAR_POWER]
mul oD1.rgb, r6, c[CONSTANT_0_05_1_2].y
mov oD1.a, c[CONSTANT_0_05_1_2].x
